package panel.recommendPathInfo
{
	import assists.HtmlText;
	import assists.Lang;
	import assists.TextFieldUtils;
	import assists.URI;
	import assists.resource.ResourceLoader;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.text.TextField;
	
	public class DescBox extends Sprite
	{
		private var _stage:Stage;
		private var _loader:ResourceLoader;
		private var _lang:Lang;
		private var _uri:URI;
		
		private var back:Bitmap;
		private var descText:TextField;
		
		private var _onRepo:Function;
		
		public function DescBox(stage:Stage, loader:ResourceLoader, lang:Lang, uri:URI)
		{
			_stage = stage;
			_loader = loader;
			_lang = lang;
			_uri = uri;
		}
		
		public function changeData(desc:String):void
		{
			descText = new TextField;
			descText.mouseEnabled = false;
			descText.multiline = true;
			descText.wordWrap = true;
			descText.width = _stage.stageWidth * .8;
			descText.x = _stage.stageWidth * .1;
			TextFieldUtils.setHtmlText(descText,HtmlText.formatSizeColor(desc,0x000000));
			descText.height = descText.textHeight + 5;
			
			back = new _loader.uiManager.paperImageBack as Bitmap;
			this.addChild(back);
			this.addChild(descText);
			
			reposition();
		}
		
		private function reposition():void
		{
			back.height = descText.height + _stage.stageWidth * .1;
			back.width = _stage.stageWidth;
			descText.y = _stage.stageWidth * .05;
			
			this.height = back.height;
			
			if(_onRepo is Function){
				_onRepo();
			}
		}
		
		public function set repo(func:Function):void
		{
			_onRepo = func;
		}
		
		public function clear():void
		{
			if(_stage){
				_stage = null;
				_loader = null;
				_lang = null;
				_uri = null;
				
				back = null;
				descText = null;
			}
		}
	}
}